import app
import requests
import logging


class LoginApi:
    def __init__(self):
        # 登录URL
        self.login_url = app.BASE_URL + "/api/sys/login"

    # 登录
    def login(self, mobile, password):
        logging.info("params mobile={} password={}".format(mobile, password))
        data = {}
        if mobile is not None:
            data["mobile"] = mobile
        if password is not None:
            data["password"] = password
        print("data=", data)

        return requests.post(self.login_url,
                             headers=app.headers_data, json=data)

    def login_no_param(self):
        data = None
        return requests.post(self.login_url, headers=app.headers_data, json=data)

